//
//  KeyViewController.m
//  30303
//
//  Created by student on 16/3/18.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "KeyViewController.h"

@interface KeyViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageview;

@end

@implementation KeyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    CGMutablePathRef path=CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 160.0, 100.0);
    CGPathAddLineToPoint(path, NULL, 100.0, 280.0);
    CGPathAddLineToPoint(path, NULL, 260.0, 170.0);
    CGPathAddLineToPoint(path, NULL, 60.0, 170.0);
    CGPathAddLineToPoint(path, NULL, 220.0, 280.0);
    CGPathCloseSubpath(path);
    
    
    
    CAKeyframeAnimation *anim=[CAKeyframeAnimation animationWithKeyPath:@"position"];
    [anim setPath:path];
    anim.duration=3;
    [self.imageview.layer addAnimation:anim forKey:nil];
    
    CFRelease(path);
    path=nil;
    
    CAKeyframeAnimation *anim2=[CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
    anim2.duration=3;
    anim2.keyTimes=@[@.2,@.4,@.6,@.8,@1];
    anim2.values=@[@0.25,@1,@0.5,@1,@2];
    [self.imageview.layer addAnimation:anim2 forKey:nil];
    
    
    
    
    
}
@end
